
import { Link } from 'umi';
import config from '@/config/config';
import { Avatar } from 'antd';
import styles from './index.less';


const mapNotice = (notices) => {
    if (!Array.isArray(notices)) {
        return [];
    }
    return notices.map(notice => {
        const newNotice = { ...notice };

        if (notice.bizCode.startsWith('ENTERPRISE')) {
            newNotice.avatar = (<Avatar className={styles.codeAvatar}>企</Avatar>)
        }
        if (notice.bizCode === "ENTERPRISE_INVITE_USER_ACCEPT") {
            newNotice.extra = (<Link to={`/enterprise/manage?tabKey=user`}>去处理</Link>)
        }
        if (notice.bizCode === "ENTERPRISE_INVITE_USER_ACCEPT_CONFIRM") {
            if (newNotice.content && newNotice.content.enterpriseId) {
                newNotice.extra = (<Link to={`/home/invite?enterpriseId=${newNotice.content.enterpriseId}`}>去处理</Link>)
            }
        }
        return newNotice;
    })

}


export { mapNotice }